var app = getApp();
Page({

  data: {
    id:0,
    type:0,
    txt:''
  },
  onLoad: function (e) {
    this.data.id = e.id;
    this.data.type = e.type;
    this.data.options = e;
    this.getLive(e.id)
  },
  txtInput(e){
    this.setData({
      txt:e.detail.value
    })
  },
  complaint(){
    let t = this,d = t.data;
    app.request({
      url:getApp().api.siteinfo.apiroot+'live/complaintRoom',
      data:{
        hosId: app.api.siteinfo.hosId,
        liveId:d.id,
        typeId:d.type,
        content:d.txt,
        mobile:wx.getStorageSync('appUserInfo').mobile
      },
      success(){
        //hosId=3&liveId=4&userId=1&access_token=123123&roomId=xxxxx&typeId=4&content=2222
        //(hos_id,live_id,room_id,access_token,create_time,type_id,content,mobile
        wx.showToast({title:'提交成功'})
        t.setData({txt:''})
      }
    })
  },
  getLive(id){
    var t = this;
    app.request({
      url:getApp().api.siteinfo.apiroot+'live/getRoomInfo',
      data:{
        hosId: app.api.siteinfo.hosId,
        liveId:id,
      },
      success(e) {
        t.setData({
          bg_img:e.background_img,
          begin_time:e.begin_time,
          title:e.room_name,
          name:app.api.siteinfo.name
        })
      }
    })
  }
})